package tests;

import java.util.Iterator;

import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;


import Model.*;

public class TaskTreeIteratorTest extends TestCase
{
	
	@Test 
	public void testHasNext() throws Exception
	{
        ComplexTask task = new ComplexTask("test", new java.sql.Date(0), "Complex");
        ComplexTask task2 = new ComplexTask("test2", new java.sql.Date(0), "Complex");
        Task task3 = new SingleTask("test3", new java.sql.Date(0), "Single");
        ComplexTask task4 = new ComplexTask("test4", new java.sql.Date(0), "Complex");
        ComplexTask task5 = new ComplexTask("test5",new java.sql.Date(0), "Complex");
                
        //nesting the tasks...
        task.addTodoItem(task2);
        task.addTodoItem(task5);
        task2.addTodoItem(task3);
        
        Iterator<Task> testIterator = task.iterator();
        Iterator<Task> testIterator2 = task4.iterator();
        
        assertTrue(testIterator.hasNext()); //if there exists a next task in the nested tree, then no exception will be thrown.
        assertFalse(testIterator2.hasNext()); //if there does not exist a next task in the single tree, then no exception will be thrown.  
	}

	@Test 
	public void testNext() throws Exception
	{
        ComplexTask task = new ComplexTask("test", new java.sql.Date(0), "Complex");
        ComplexTask task2 = new ComplexTask("test2", new java.sql.Date(0), "Complex");
        Task task3 = new SingleTask("test3", new java.sql.Date(0), "Single");
        ComplexTask task4 = new ComplexTask("test4", new java.sql.Date(0), "Complex");
        ComplexTask task5 = new ComplexTask("test5",new java.sql.Date(0), "Complex");
        ComplexTask task6 = new ComplexTask("test6",new java.sql.Date(0),"Complex");
        
      //nesting the tasks...
        task2.addTodoItem(task3);
        task2.addTodoItem(task4);
        task.addTodoItem(task2);
        task.addTodoItem(task5);
        task5.addTodoItem(task6);
        
        Iterator<Task> testIterator = task.iterator();
        
        Task nextTask = null;
        
        nextTask = testIterator.next();
        nextTask = testIterator.next();
        nextTask = testIterator.next();
        nextTask = testIterator.next();
        nextTask = testIterator.next();

        TaskTreeIterator f1 = (TaskTreeIterator)testIterator;        
	}
	
}